package com.hqsj.service;

import com.github.sd4324530.fastweixin.api.MaterialAPI;
import com.github.sd4324530.fastweixin.api.enums.MaterialType;
import com.github.sd4324530.fastweixin.api.response.GetMaterialListResponse;
import com.github.sd4324530.fastweixin.api.response.GetMaterialTotalCountResponse;
import com.github.sd4324530.fastweixin.util.JSONUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by huangying on 2017/4/13.
 */
@Service
public class MaterialServiceImpl implements MaterialService {

    @Autowired
    MaterialAPI materialAPI;

    @Override
    public GetMaterialListResponse test() {
        GetMaterialTotalCountResponse getMaterialTotalCountResponse = materialAPI.countMaterial();
        GetMaterialListResponse getMaterialListResponse = materialAPI.batchGetMaterial(MaterialType.NEWS, 0, 4);
        List<Map<String, Object>> list = getMaterialListResponse.getItems();

        System.out.println(JSONUtil.toJson(list));
//        for (int i = 0; i < list.size(); i++) {
//            Map<String, Object> map = list.get(i);
//            System.out.println(map);
//        }
        System.out.println(getMaterialTotalCountResponse.toString());
        return getMaterialListResponse;
    }
}
